package com.yequan.designpattern.proxy.dynamic_proxy.jdk.second_generation;

import com.yequan.designpattern.proxy.dynamic_proxy.GamePlayer;
import com.yequan.designpattern.proxy.dynamic_proxy.IGamePlayer;

import java.lang.reflect.InvocationHandler;

public class SecondGenerationJdkTest {

    public static void main(String[] args) {
        IGamePlayer gamePlayer = new GamePlayer("叶权");
        InvocationHandler myInvocationHandler = new MyInvocationHandler(gamePlayer);
        IGamePlayer proxyInstance =
                DynamicProxy.newProxyInstance(gamePlayer.getClass().getClassLoader(), gamePlayer.getClass().getInterfaces(), myInvocationHandler);
        proxyInstance.login("yequan", "1");
        System.out.println("\n");
        proxyInstance.killBoss();
        System.out.println("\n");
        proxyInstance.upgrade();
    }

}
